package com.rany.day03.demo05;

import java.util.ArrayList;

public class Manager extends User {
    public Manager() {
    }

    public Manager(String name, int money) {
        super(name, money);
    }

    public ArrayList<Integer> send (int totalMoney,int count){
        //使用集合存储若干红包的金额
        ArrayList<Integer> redList =  new ArrayList<>();
        //群主红包金额
        int leftMonry = super.getMoney();
        //发红包
        if(totalMoney > leftMonry){
            System.out.println("抱歉！余额不足！");
            return redList;
        }

        //群主扣钱
        super.setMoney(leftMonry-totalMoney);

        //需要拆分
        int avg = totalMoney/count;
        int mod = totalMoney%count; // 余数

        for (int i = 0; i < count -1; i++) {
            redList.add(avg);
        }

        int last = avg + mod;
        redList.add(last);

        return redList;
    }
}
